Substitute kmalloc+memset by kzalloc where possible
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Fri, 17 Mar 2006 09:52:05 +0000 (09:52 +0000)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Fri, 17 Mar 2006 09:52:05 +0000 (09:52 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c

index b1934d129bc35b867b85e0199bbe21dbe3b82f1f..82625a97157abf697b8e4abb3f0cc0bfbaeba24d 100644 (file)
@@ -116,15 +116,13 @@ static int blkback_probe(struct xenbus_device *dev,
                         const struct xenbus_device_id *id)
 {
        int err;
-       struct backend_info *be = kmalloc(sizeof(struct backend_info),
+       struct backend_info *be = kzalloc(sizeof(struct backend_info),
                                          GFP_KERNEL);
        if (!be) {
                xenbus_dev_fatal(dev, -ENOMEM,
                                 "allocating backend structure");
                return -ENOMEM;
        }
-       memset(be, 0, sizeof(*be));
-
        be->dev = dev;
        dev->data = be;
 
index 5e0b8be45921af2af979ec05acf496dc545f3c4a..240afd2b0e5b037a5260f7b504566f4610711199 100644 (file)
@@ -90,13 +90,12 @@ static int blkfront_probe(struct xenbus_device *dev,
                return err;
        }
 
-       info = kmalloc(sizeof(*info), GFP_KERNEL);
+       info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {
                xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure");
                return -ENOMEM;
        }
 
-       memset(info, 0, sizeof(*info));
        info->xbdev = dev;
        info->vdevice = vdevice;
        info->connected = BLKIF_STATE_DISCONNECTED;
index b092a569aee9b721cf096468c39bf88b35f8d77e..99b8ab1a990d67659a944f97b7dbd304e607c868 100644 (file)
@@ -97,12 +97,10 @@ xlbd_alloc_major_info(int major, int minor, int index)
 {
        struct xlbd_major_info *ptr;
 
-       ptr = kmalloc(sizeof(struct xlbd_major_info), GFP_KERNEL);
+       ptr = kzalloc(sizeof(struct xlbd_major_info), GFP_KERNEL);
        if (ptr == NULL)
                return NULL;
 
-       memset(ptr, 0, sizeof(struct xlbd_major_info));
-
        ptr->major = major;
 
        switch (index) {
index 3dc91674a78bcc85aa4baa1395186cd3d51e0c91..d97660d70170ac99cc36314dbf06ace482ebcceb 100644 (file)
@@ -141,12 +141,11 @@ static int blkback_probe(struct xenbus_device *dev,
        char *frontend;
        int err;
 
-       be = kmalloc(sizeof(*be), GFP_KERNEL);
+       be = kzalloc(sizeof(*be), GFP_KERNEL);
        if (!be) {
                xenbus_dev_error(dev, -ENOMEM, "allocating backend structure");
                return -ENOMEM;
        }
-       memset(be, 0, sizeof(*be));
 
        frontend = NULL;
        err = xenbus_gather(dev->nodename,
index 64bebdb820759d820c037b5a41189655b62bbd1d..526e02ab0ab3b228b38db227b9587e9c1b58d3a4 100644 (file)
@@ -76,14 +76,13 @@ static int netback_probe(struct xenbus_device *dev,
                         const struct xenbus_device_id *id)
 {
        int err;
-       struct backend_info *be = kmalloc(sizeof(struct backend_info),
+       struct backend_info *be = kzalloc(sizeof(struct backend_info),
                                          GFP_KERNEL);
        if (!be) {
                xenbus_dev_fatal(dev, -ENOMEM,
                                 "allocating backend structure");
                return -ENOMEM;
        }
-       memset(be, 0, sizeof(*be));
 
        be->dev = dev;
        dev->data = be;
index 9a2be8d593a4d47b78cf5a61eb8093c13e332d81..6ce5f0789144088e05044189ef2fd04833140273 100644 (file)
@@ -67,7 +67,7 @@ static int tpmback_probe(struct xenbus_device *dev,
                          const struct xenbus_device_id *id)
 {
        int err;
-       struct backend_info *be = kmalloc(sizeof(struct backend_info),
+       struct backend_info *be = kzalloc(sizeof(struct backend_info),
                                          GFP_KERNEL);
 
        if (!be) {
@@ -76,8 +76,6 @@ static int tpmback_probe(struct xenbus_device *dev,
                return -ENOMEM;
        }
 
-       memset(be, 0, sizeof(*be));
-
        be->is_instance_set = 0;
        be->dev = dev;
        dev->data = be;
index cdab7e82c2eee628210c18e7cee75d046e028b9d..9b51e4b4ebb89faab5885fce89e1960eb2c8cc0b 100644 (file)
@@ -179,11 +179,10 @@ static int xenbus_dev_open(struct inode *inode, struct file *filp)
 
        nonseekable_open(inode, filp);
 
-       u = kmalloc(sizeof(*u), GFP_KERNEL);
+       u = kzalloc(sizeof(*u), GFP_KERNEL);
        if (u == NULL)
                return -ENOMEM;
 
-       memset(u, 0, sizeof(*u));
        INIT_LIST_HEAD(&u->transactions);
        init_waitqueue_head(&u->read_waitq);
 
index a130cbcf729921543fd89da77884b399fbe9a11b..017f36ccddb10429671d5dd937db45cd5d015686 100644 (file)
@@ -552,10 +552,9 @@ static int xenbus_probe_node(struct xen_bus_type *bus,
        }
 
        stringlen = strlen(nodename) + 1 + strlen(type) + 1;
-       xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
+       xendev = kzalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
        if (!xendev)
                return -ENOMEM;
-       memset(xendev, 0, sizeof(*xendev));
 
        /* Copy the strings into the extra space. */